package com.woniu.learnredirect.controller;

import com.woniu.learnredirect.entity.User;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;

/**
 * created by woniu201
 * created in 2018/4/12
 */
@RestController
public class TestController {

    @RequestMapping(value = "/test1", method = RequestMethod.GET)
    public String test1(HttpServletRequest req){
        Enumeration<String> keys = req.getParameterNames();
        while(keys.hasMoreElements()) {
            String k = keys.nextElement();
            System.out.println(k + " = " + req.getParameter(k) );
        }
        return "重定向测试test1";
    }

    @RequestMapping(value = "/test1/a", method = RequestMethod.GET)
    public String test2(HttpServletRequest req){
        Enumeration<String> keys = req.getParameterNames();
        while(keys.hasMoreElements()) {
            String k = keys.nextElement();
            System.out.println(k + " = " + req.getParameter(k) );
        }
        return "重定向测试test1/a";
    }

    @RequestMapping(value = "/test1/a/b", method = RequestMethod.GET)
    public String test3(HttpServletRequest req){
        Enumeration<String> keys = req.getParameterNames();
        while(keys.hasMoreElements()) {
            String k = keys.nextElement();
            System.out.println(k + " = " + req.getParameter(k) );
        }
        System.out.println("aaa");
        return "重定向测试test1/a/b";
    }

    @RequestMapping(value = "/test1/a/b/c", method = RequestMethod.GET)
    public String test4(HttpServletRequest req){
        Enumeration<String> keys = req.getParameterNames();
        while(keys.hasMoreElements()) {
            String k = keys.nextElement();
            System.out.println(k + " = " + req.getParameter(k) );
        }
        return "重定向测试test1/a/b/c";
    }

}
